/**
 * 统计报表
 */
import Vue from 'vue'
const SUCCESS = 1000000
const API_ROOT = server.root + '/newmanage/invite'

const inviteResource = Vue.resource(API_ROOT + '/list')
export const getInviteUserList = ({dispatch}, params) => {
  return inviteResource.get(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        dispatch('INVITE_LIST_FRESH', 0)
        return Promise.resolve(res.data.data)
      }
      return Promise.reject(res.data)
    })
}

const promoterSettleImportResource = Vue.resource(API_ROOT + '/import')
export const importInviteUserList = ({dispatch}, params) => {
  return promoterSettleImportResource.save(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        return dispatch('INVITE_LIST_FRESH', 1)
      }
      return Promise.reject(res.data)
    })
}
const confirmResource = Vue.resource(API_ROOT + '/confirm')
export const confirm = ({dispatch}, params) => {
  return confirmResource.save(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        return dispatch('INVITE_LIST_FRESH', 1)
      }
      return Promise.reject(res.data)
    })
}